//
//  LatentCustomerCCell.m
//  WGFGlobalHouses
//
//  Created by waiguofang on 15/5/5.
//  Copyright (c) 2015年 waiguofang. All rights reserved.
//   潜在客户的cell

#import "LatentCustomerCCell.h"

@interface LatentCustomerCCell()

//flag = 0 转为真实客户，＝ 1 锁定
@property(nonatomic,assign) NSInteger flag;

@end
@implementation LatentCustomerCCell
-(void)initWithTableView:(UITableView *)tableView withModel:(CustomerModel *)model
{
    self.delegate = tableView;
    
    self.showFuntionBtn1 = true;
    self.showFuntionBtn2 = true;
    self.showFuntionBtn3 = NO;
    
    
    
    
    self.customerView= [LatentCustomerView  createViewWithModel:model];
    
    [self.funtionBtn1 addTarget:self action:@selector(btnOnClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.funtionBtn2 addTarget:self action:@selector(btnOnClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.funtionBtn3 addTarget:self action:@selector(btnOnClick:) forControlEvents:UIControlEventTouchUpInside];
    
    
    [self.customerView setFrame:CGRectMake(0, 0, self.contentMoveView.frame.size.width, self.contentMoveView.frame.size.height)];
    
    [self.contentMoveView addSubview:self.customerView];
}

-(void)setModel:(CustomerModel *)model
{
    _model = model;
    self.customerView.model = model;
    
    
    if (model.dateNum >= 0) { //有限期大于0天的（转为真实客户，编辑）
        
        self.showFuntionBtn3 = NO;
        [self LatentCustomerBtn:@""];
        
    }else if (model.dateNum <= -3)//有限期天数超过3天（转为真实客户，锁定，编辑）
    {
        [self LatentCustomerBtn:@"1"];
        self.showFuntionBtn3 = YES;
         [self LatentCustomerBtn:@"1"];
    }else if (model.dateNum<= 0 && model.dateNum > -3)//有限期期天数超过0-3天，（转为真实客户，编辑）
    {
        
        self.showFuntionBtn3 = NO;
        [self LatentCustomerBtn:@""];
    }
    [self setContentHight:60];
   
}


-(void)btnOnClick:(UIButton *)btn
{
    NSInteger tag = btn.tag;
    switch (tag) {
        case 101://编辑
        {
            if (self.btnDelegate && [self.btnDelegate respondsToSelector:@selector(LatentCustomerCCellDidClickEditBtnWithModel:)]) {
                [self.btnDelegate LatentCustomerCCellDidClickEditBtnWithModel:self.model];
            }
        }
            
            break;
        case 102://转为真实客户
        {
            if (self.btnDelegate && [self.btnDelegate respondsToSelector:@selector(LatentCustomerCCellDidClickpotentialchangtorealWithModel: withCell:)]) {
                    [self.btnDelegate LatentCustomerCCellDidClickpotentialchangtorealWithModel:self.model withCell:self];
                }
           }
            
            break;
        case 103://锁定
        {
            if (self.btnDelegate && [self.btnDelegate respondsToSelector:@selector(LatentCustomerCCellDidClickLockBtnWithPotentialId: withCell:)]) {
                [self.btnDelegate  LatentCustomerCCellDidClickLockBtnWithPotentialId:self.model.consumerId withCell:self];
            }
        }
            break;
        default:
            break;
    }
}

-(void)setIsEditMode:(Boolean)isEditMode{
    
    
    [self cloadMenu];
    
    [self setScrollAble:!isEditMode];
    
    [self.customerView setIsEditMode:isEditMode];
}

@end

